package com.sunxueqi.framework.security;

import java.util.Collection;
import java.util.Set;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sunxueqi.project.system.vo.User;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class LoginUser implements UserDetails{
	
	private static final long serialVersionUID = 1L;

	private String token;
	
	private Long loginTime;
	
	private Long time;
	
	private Long expireTime;
	
	private String ip;
	
	private String location;
	
	private String browser;
	
	private String os;
	
	private Set<String> permissions;
	
	private User user;

	public LoginUser (User user, Set<String> permissions) {
		this.user = user;
		this.permissions = permissions;
	}
	
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}

	@JsonIgnore
	@Override
	public String getPassword() {
		return user.getPassword();
	}

	@Override
	public String getUsername() {
		return user.getUsername();
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isEnabled() {
		return true;
	}

}
